package com.nf.health.app.inquiry.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;

import com.nf.health.app.R;
import com.nf.health.app.activity.global.BaseActivity;
import com.nf.health.app.utils.ViewUtil;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by hepann on 2016/4/26.
 * The only genius that is worth anything is the genius for hard work
 *
 * @author hepann
 * @Description 患者姓名添加 //这tmd也一个单独的activity,不知道产品咋想的
 * @email he_pann@163.com
 */
public class AddPatientNameActivity extends BaseActivity {
    @Bind(R.id.tv_name)
    EditText tvName;
    @Bind(R.id.ll_name)
    LinearLayout llName;
    @Bind(R.id.btn_commit)
    Button btnCommit;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitleBar(R.layout.titlebar_base);
        setContent(R.layout.activity_add_patient_name);
        ButterKnife.bind(this);

        ViewUtil.setText(this, R.id.titlebar_title_tv, "患者姓名");
        initListener();
    }

    private void initListener() {
        btnCommit.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.btn_commit:
                String name = tvName.getText().toString().trim();
                if (TextUtils.isEmpty(name)) {
                    showToast("名字不能为空");
                    return;
                }
                Intent intent = new Intent();
                Bundle bundle = new Bundle();
                bundle.putString("name", name);
                intent.putExtras(bundle);
                setResult(RESULT_OK, intent); //intent为A传来的带有Bundle的intent，当然也可以自己定义新的Bundle
                finish();//此处一定要调用finish()方法
                break;

            default:
                break;
        }
    }
}
